package qf.api.controller.gateway;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import qf.api.service.MyBatisFeignService;
import qf.common.core.web.vo.AjaxResult;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;

@RestController
@RequestMapping("gateway/api")
public class GateWayController {

    @Resource
    MyBatisFeignService service;

    @RequestMapping("/v1/test")
    @PreAuthorize("hasAuthority('admin')")
    public AjaxResult myBatisTest(@PathParam(value = "name") String name) {
        System.out.println("我进来啦！！！！！" + name);
        return service.myBatisTest();
    }

    @RequestMapping("/v2/test")
    public AjaxResult myBatisTest(@RequestBody Object obj) {
        System.out.println("我进来啦！！！！！" + obj.toString());
        return service.saveBatisTest(obj);
    }



    @RequestMapping("/v3/test")
    public AjaxResult myBatisTest() {
        System.out.println("我进来啦！！！！！" );
        return service.myBatisTest();
    }

    @RequestMapping("/v4/test")
    public AjaxResult redisTest(@PathParam(value = "key") String key) {
        System.out.println("我进来啦！！！！！" );
        return service.myRedisTest(key);
    }
}
